package com.example.traning.mall.controller.dict;

import com.example.traning.mall.framework.common.pojo.R;
import com.example.traning.mall.service.dict.IDictDistrictService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import lombok.RequiredArgsConstructor;

import java.util.List;

/**
 * <p>
 * 省市区字典 前端控制器
 * </p>
 *
 * @author Lei Yu
 * @since 2025-04-29
 */
@Tag(name = "1. 字典数据-省市区")
@RestController
@RequestMapping("/dict/district")
public class DictDistrictController {

    @Resource
    private  IDictDistrictService service;

    @Operation(summary = "根据父级查询子级地区列表")
    @GetMapping("/list-by-parent")
    public R selectByParentId(
            @RequestParam(value = "parentId", required = false)
            String parentId) {
        return R.ok(service.selectByParentId(parentId));
    }

}
